home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Lib / table / tb_getuser.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  2.1 KB  |  90 lines

  1. /* tb_getuser.c: grab an user */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Lib/table/RCS/tb_getuser.c,v 6.0 1991/12/18 20:24:28 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Lib/table/RCS/tb_getuser.c,v 6.0 1991/12/18 20:24:28 jpo Rel $
  9.  *
  10.  * $Log: tb_getuser.c,v $
  11.  * Revision 6.0  1991/12/18  20:24:28  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include        "util.h"
  19. #include        "chan.h"
  20. #include        "list_rchan.h"
  21.  
  22.  
  23. #define         MAX_ALTERNATIVE_CHANS           20
  24. #define        MAX_USER_ARGS            5
  25.  
  26. /* ---------------------  Begin  Routines  -------------------------------- */
  27.  
  28.  
  29. extern char    *user_tbl, *loc_dom_mta;
  30.  
  31. LIST_RCHAN    *tb_getuser (key, subdom)
  32. char        *key;
  33. char        *subdom;
  34. {
  35.     char    *argv [MAX_ALTERNATIVE_CHANS],
  36.         *subargv[MAX_USER_ARGS],
  37.         buf [BUFSIZ],
  38.         tblname[MAXPATHLENGTH];
  39.     int    argc, i;
  40.     Table    *User = NULLTBL;
  41.     LIST_RCHAN    *chans = NULLIST_RCHAN, *tmp;
  42.  
  43.     if (subdom == NULLCP || *subdom == '\0')
  44.         (void) sprintf(tblname,"%s", user_tbl);
  45.     else
  46.         (void) sprintf(tblname,"%s-%s", subdom, user_tbl);
  47.  
  48.  
  49.     PP_DBG (("Lib/tb_getuser (%s)", tblname));
  50.  
  51.  
  52.     if ((User = tb_nm2struct (tblname)) == NULLTBL) {
  53.         PP_OPER (NULLCP, ("Lib/tb_getuser (no table '%s')", tblname));
  54.         return (NULLIST_RCHAN);
  55.     }
  56.  
  57.     if (tb_k2val (User, key, buf, TRUE) == NOTOK)
  58.         return (NULLIST_RCHAN);
  59.  
  60.     if ((argc = sstr2arg (buf, MAX_ALTERNATIVE_CHANS, argv, ",")) == NOTOK)
  61.         return (NULLIST_RCHAN);
  62.  
  63.     for (i = 0; i < argc; i++) {
  64.         if (!isstr(argv[i]))
  65.             continue;
  66.             
  67.         if ((sstr2arg (argv[i], MAX_USER_ARGS, subargv, " ")) == NOTOK) {
  68.             PP_LOG(LLOG_EXCEPTIONS,
  69.                    ("Unable to parse delivery channels for '%s' in the user table '%s'",  
  70.                 key, tblname));
  71.             list_rchan_free(chans);
  72.             return NULLIST_RCHAN;
  73.         }
  74.         if ((tmp = list_rchan_new ((subargv[1] == NULLCP ||
  75.                         *subargv[1] == '\0') ?
  76.                        loc_dom_mta : subargv[1],
  77.                        NULLCP)) == NULLIST_RCHAN) {
  78.             PP_LOG(LLOG_EXCEPTIONS,
  79.                    ("Unable to find delivery channel '%s' for '%s' in the user table '%s'",  
  80.                 argv[0], key, tblname));
  81.             list_rchan_free(chans);
  82.             return NULLIST_RCHAN;
  83.         }
  84.         tmp -> li_chan = ch_nm2struct(subargv[0]);
  85.         list_rchan_add (&chans, tmp);
  86.     }
  87.     return (chans);
  88. }
  89.  
  90.